package com.leijie.nio;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author LeiJie
 * @time 2020-5-9 14:20
 * @desc TODO
 */
public class NioTest2 {

    public static void main(String[] args) throws IOException {

        FileInputStream inputStream = new FileInputStream("NioTest2.txt");

        FileChannel channel = inputStream.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(512);
        channel.read(buffer);

        buffer.flip();
        while (buffer.hasRemaining()){
            byte b = buffer.get();
            System.out.println("content:"+(char)b);
        }

        channel.close();
    }

}
